#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Precision.h>
#include <cmath>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

struct testData
{
    double src;
    double dst;
};

FIXTURE(Precision)
{
    TEST(Precision floor should be right)
    {
        testData data[]=
        {
                {5.01, 5.01},
                {5.011,5.01},
                {5.012,5.01},
                {5.013,5.01},
                {5.014,5.01},
                {5.015,5.01},
                {5.016,5.01},
                {5.017,5.01},
                {5.018,5.01},
                {5.019,5.01},
                {5.020,5.02}
        };

        for(int i=0;i<sizeof(data)/sizeof(testData);i++)
        {
           const Precision precision(2, std::floor);
           ASSERT_EQ(data[i].dst, precision(data[i].src));
        }
    }

    TEST(Precision round should be right)
     {
         testData data[]=
         {
                 {5.01, 5.01},
                 {5.011,5.01},
                 {5.012,5.01},
                 {5.013,5.01},
                 {5.014,5.01},
                 {5.015,5.02},
                 {5.016,5.02},
                 {5.017,5.02},
                 {5.018,5.02},
                 {5.019,5.02},
                 {5.020,5.02}
         };

         for(int i=0;i<sizeof(data)/sizeof(testData);i++)
         {
            const Precision precision(2, round);
            ASSERT_EQ(data[i].dst, precision(data[i].src));
         }
     }


};

